package com.gper.edu.extractor

object SeqExtractor {
  def unapplySeq(fullName: String): Option[(String,String,Seq[String])] = {
    val names = fullName.split(" ");
    if(names.size < 2) None
    else Some((names.last,names.head,names.drop(1).dropRight(1)))
  }

  def greet(fullName: String) = fullName match {
    case SeqExtractor(lastName,firstName,_*) => s"Good morning,$firstName $lastName"
    case _ => "Welcome! please make sure to fill in your name!"
  }
  def main(args: Array[String]): Unit = {
    print(greet("Matthew John Michael"))
  }
}
